import uvicorn
from fastapi import FastAPI
from starlette.middleware.cors import CORSMiddleware

from business.front.user import user as front_user
from business.job import job
from business.mgr.goods import goods
from business.mgr.order import order
from business.mgr.user import user as mgr_user
from business.sys import init

app = FastAPI()

app.include_router(mgr_user.router)
app.include_router(front_user.router)
app.include_router(order.router)
app.include_router(goods.router)
#app.include_router(job.router)
app.include_router(init.router)

# origins = ["http://127.0.0.1:5500"]   #限定访问地址
origins = ["*"]  # 允许所有地址访问

app.add_middleware(
    CORSMiddleware,
    allow_origins=origins,
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

if __name__ == '__main__':
    uvicorn.run(app, host="127.0.0.1", port=8089)
